//
//  ComSumerTableViewCell.m
//  CarTown
//
//  Created by xionghao on 15/8/26.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "ComSumerTableViewCell.h"
#import "GuzhuType.h"
#import <UIImageView+WebCache.h>
#define kTableTopBorderWidth 8
@implementation ComSumerTableViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView{
    ComSumerTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"comsumer"];
    return cell;
}

-(void)setIsEidt:(BOOL)isEidt{
    _isEidt=isEidt;
    self.editbutton.hidden=!_isEidt;
    if (_isEidt) {
        self.accessoryType=UITableViewCellAccessoryNone;
    }else{
        self.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    }
}

- (void)awakeFromNib {
    // Initialization code
    self.icon.layer.cornerRadius=self.icon.width/2;
    self.icon.layer.borderColor=[tintblue CGColor];
    self.icon.layer.borderWidth=0.5;
    self.icon.clipsToBounds=YES;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(void)setType:(GuzhuType *)type{
    _type=type;
    self.editbutton.selected=_type.ischecked;
    if (_type.user_id) {
        self.name.text=_type.user_truename;
        [self.icon sd_setImageWithURL:[NSURL URLWithString:[NSString getImageURLstr:_type.user_ico]] placeholderImage:[UIImage imageNamed:@"usericon_placehoder"]];
        self.info.text=_type.user_intro;
        
    }else{
        self.name.text=_type.shop_name;
        [self.icon sd_setImageWithURL:[NSURL URLWithString:[NSString getImageURLstr:_type.shop_logo]] placeholderImage:[UIImage imageNamed:@"usericon_placehoder"]];
        self.info.text=_type.shop_intro;
    }
    if ([_type.cat_name isEqualToString:@"个人商铺"]) {
        self.typeicon.image=[UIImage imageNamed:@"ico_p"];
    }
   else if ([_type.cat_name isEqualToString:@"综合销售店"]) {
        self.typeicon.image=[UIImage imageNamed:@"ico_zonghe"];
    }
   else if ([_type.cat_name isEqualToString:@"4S店"]) {
        self.typeicon.image=[UIImage imageNamed:@"ico_4s"];
    }
   else if ([_type.cat_name isEqualToString:@"港口批发商"]) {
        self.typeicon.image=[UIImage imageNamed:@"ico_hk"];
    }
   else if ([_type.cat_name isEqualToString:@"资源公司"]) {
        self.typeicon.image=[UIImage imageNamed:@"ico_z"];
    }
    
}

-(void)setFrame:(CGRect)frame{
    frame.origin.y += kTableTopBorderWidth;
    frame.size.height -= kTableTopBorderWidth;
    
    [super setFrame:frame];
    
}
@end
